package com.lyy.photovoltaic.controller;

import com.lyy.photovoltaic.beans.UsersInfo;
import com.lyy.photovoltaic.common.vo.ResultVO;

import com.lyy.photovoltaic.service.UsersInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/userInfo")
@Api(value = "用户信息的增删改查", tags = "用户信息管理")
public class UsersInfoController {
    @Autowired
    private UsersInfoService usersInfoService;
    @ApiOperation(value = "查询单个用户信息接口")
    @GetMapping(value = "/{uiid}")
    @ApiImplicitParam(dataType = "string", name = "uiid", value = "查询用户信息", required = true)
    public ResultVO findUserById(@PathVariable("uiid") String uiid) {

//        System.out.println("查询成功了");
        ResultVO resultVO = usersInfoService.findUserInfoById(uiid);
        return resultVO;
    }
    @ApiOperation(value = "根据用户Id查询单个用户信息接口")
    @GetMapping(value = "/uId/{uId}")
    @ApiImplicitParam(dataType = "string", name = "uId", value = "查询用户信息", required = true)
    public ResultVO findUserByUId(@PathVariable("uId") String uId) {

//        System.out.println("查询成功了");
        ResultVO resultVO = usersInfoService.findUserInfoByUId(uId);
        return resultVO;
    }
    @PutMapping(value = "/{uiid}")
    public ResultVO updateEquipment(@RequestBody UsersInfo userInfo) {
        ResultVO resultVO = usersInfoService.updateUserInfo(userInfo);
        return resultVO;
    }
    @ApiOperation(value = "根据用户Id查询单个用户信息接口")
    @GetMapping(value = "/findAllUserInfo")
    public ResultVO findAllUserInfo() {
        ResultVO resultVO = usersInfoService.findAllUserInfo();
        return resultVO;
    }
}
